<template>
	<view>

		<view v-for="(item,index) in confirm_list" :key="item.transferid" class="truck_item"
			@click="onScanLoad(item,'1')">
			<view class="div_item">
				<view>发往<span>{{item.addrto || '--'}}</span></view>
				<view>卸货点 <span>{{item.addrxhd || '--'}}</span></view>
			</view>
			<view class="div_item">
				<view>车牌号<span>{{item.vehicleNo || '--'}}</span></view>
				<view>装车单号<span>{{item.loadNo || '--'}}</span></view>
			</view>
			<!-- 		<view class="div_item">
				<view>保证金<span>{{item.bond || '--'}}</span></view>
				<view>支付状态<span>{{item.car.bond_status || '--'}}</span></view>
			</view> -->
			<view class="div_item">
				<view>运单数<span>{{item.waybill.length}}</span></view>
				<!-- <view>电话<span>--</span></view> -->
			</view>

			<!-- 底部操作菜单 -->
			<view class="op_menu_div">
				<view class="btn_share" @click.stop="onApplyFeight(item)">申请车费</view>
				<view class="btn_share" @click.stop="onWbList(item)">收款</view>
			</view>

		</view>

		<view v-if="!confirm_list || confirm_list.length <= 0"
			style="width: 100vw;height: 80vh;text-align: center;margin: 38vh 0 0 0;">
			暂无数据~
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				truck: {}, // 分享传过来的车次信息
				confirm_list: [], // 司机确认分享的车次订单列表
			}
		},
		onLoad(open) {
			// uni.setStorageSync('token', "63698e02-e47e-45a8-9ddd-75fc5d4d03a8")

			let that = this

			// open.id = '85'
			// 	open.truck =
			// 		`{
			// "transferid": "adbec6c9229b4919b42cfec621f309ad",
			// "fromlocation": 371300,
			// "addrfrom": "临沂",
			// "addrfromnode": "临沂(总部)",
			// "addrto": "铁西",
			// "tolocation": 210106,
			// "addrxhd": "铁西站点",
			// "xhd": "29fa509c115d490fb8e5e958ce712244",
			// "loadno": "ZC2409290001",
			// "loaddt": "2024-09-29",
			// "vehicleid": "4511349e98ff4615997191f3bdd9353e",
			// "vehicleno": "鲁QL27z6",
			// "vehiclenetweight": 0.0,
			// "drivercard": "",
			// "vehicleload": 0.0,
			// "drivername": "高",
			// "drivertel": "13153977666",
			// "gpsname": "",
			// "handingman": "",
			// "handingfee": 0.00,
			// "handingfeetype": 0,
			// "forkman": "",
			// "forkfee": 0.00,
			// "forkfeetype": 0,
			// "freight1": 0.00,
			// "freight1type": 0,
			// "freight2": 0.00,
			// "freight3": 0.00,
			// "insurancefee": 0.00,
			// "insurancefeetype": 0,
			// "feeremark": "",
			// "totaldoccount": 0,
			// "totalfreight": 0.00,
			// "freightyf": 0.00,
			// "freighttf": 0.00,
			// "freighthf": 0.00,
			// "freightkf": 0.00,
			// "freightyj": 0.00,
			// "totalGoodsQuantity": 0,
			// "totalGoodsVolume": 0.0,
			// "totalGoodsWeight": 0.0,
			// 			"detailModel": []
			// 					}`

			if (open && (open.id || open.truck)) {
				uni.setStorageSync('share_id', open.id)
				that.truck = JSON.parse(open.truck)
				uni.navigateTo({
					// url: `/pages/index/baobanyuangong?id=${open.id}&truck=${open.truck}`
					url: `/pages/index/tianxiexinxiAB?type=2&share_id=${open.id}&truck=${JSON.stringify(that.truck)}`
				})
			}

			if (!uni.getStorageSync('token')) {
				uni.navigateTo({ url: '/pages/logon/logon' })
			} else {
				// this.index_index(); //首页信息
				// this.cars_Info();   //车辆信息 
			}

			that.getOrderList()

			// 事件总线:提付运费收款成功
			uni.$on('onPaySuccess', data => {
				console.log('监听到事件来自收款页面,携带参数 data =', data);
				that.getOrderList()
			})

		},
		methods: {

			// 查看运单列表
			onWbList(item) {
				if (!item.waybill || item.waybill.length <= 0) {
					uni.showToast({ title: '该车次不存在收款运单', icon: 'none' })
					return
				}
				uni.navigateTo({
					url: `/pages/i2/waybill_list/waybill_list?truck=${JSON.stringify(item)}`
				})
			},

			// 申请车费
			onApplyFeight(item) {
				// uni.showToast({ title: '申请车费开发中', icon: 'none' })
				uni.navigateTo({
					url: `/pages/i2/apply_freight/apply_freight?truck=${JSON.stringify(item)}`
				})
			},

			// 获取订单列表(shwl)
			async getOrderList() {
				let that = this
				let res = await that.$rqt.getOrderList({
					memberid: that.memberid,
					accountid: that.accountid,
					transferstatus: that.transferstatus,
					transferid: that.transferid,
				})
				console.log('getOrderList.res = ', res);
				console.log('司机端获取到的车次信息 = ', that.truck);

				this.confirm_list = res.data

			},

		},

		onPullDownRefresh() {
			this.getOrderList()
		},

	}
</script>

<style scoped>
	.truck_item {
		margin: 20rpx;
		border: solid 1rpx rgba(0, 0, 0, 0.15);
		border-radius: 10rpx;
	}

	.div_item {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin: 14rpx 14rpx 0 14rpx;
		font-size: 28rpx;
	}

	span {
		/* display: block; */
		margin: 0 0 0 10rpx;
		color: #1890FF;
		font-size: 26rpx;
	}

	.op_menu_div {
		display: flex;
		justify-content: flex-end;
		padding: 14rpx;
	}

	.btn_share {
		background-color: #1890FF;
		width: 118rpx;
		height: 52rpx;
		line-height: 52rpx;
		text-align: center;
		font-size: 24rpx;
		color: white;
		border-radius: 4rpx;
		margin: 0 0 0 12rpx;
	}
</style>